<%@ page language="java" %>
<%@ page import="com.scalar.chiptrack.utils.ConfigManager"%>
<%@ page import="com.scalar.chiptrack.commons.Constants" %>
<%@ page import="com.scalar.chiptrack.users.Functionality" %>
<%@ page import="com.scalar.chiptrack.users.User" %>
<%@ page import="com.scalar.chiptrack.utils.StringUtils" %>


<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>

<chiptrack:checkLogon sourcePage="/proformaInvoice.do"/>
<%--
<%
    try
    {
%>
--%>
<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<SCRIPT language="JavaScript">

function cancelAndGoBack()
{
    document.proformaInvoiceForm.action = '<%=chipTracContext%>/newproformaInvoice.do?action=searchNew';
    document.proformaInvoiceForm.submit();
}

function cancelInvoice()
{
    document.proformaInvoiceForm.action='<%=chipTracContext%>/newproformaInvoice.do?action=update&isCancelled=true';
    document.proformaInvoiceForm.submit();
}
function sendMail( invoiceId, invoiceNo )
{
    window.open ('<%=chipTracContext%>/proformaInvoiceSendMail.do?invoiceId=' + invoiceId + '&invoiceNo=' + invoiceNo , 'sendProformaMailPopup1','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=800,height=550,resizable=yes');
}
function printView( invoiceId )
{
	newWindow = window.open ('<%=chipTracContext%>/newproformaInvoice.do?action=print_view&invoiceId='+invoiceId,'printerFreindlyPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=800,height=550,resizable=yes');
}
</SCRIPT>
</HEAD>
<BODY bgColor='#ffffff' leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<!-- Top Header Start-->
<%@include file="/jsp/includes/header.jsp"  %>
<!-- Top Header End-->
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
    <tr>
	    <td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
            <!-- Side Navigation start -->
            <%@include file="/jsp/finance/finance_menu.jsp" %>
            <!-- end of the side navigations -->
        </td>
        <%--<td bgcolor="#ffffff"><img height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></td>
        <td bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></td>--%>
        <td valign="top" width="100%"><img height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
            <html:form name="proformaInvoiceForm" type="com.scalar.chiptrack.finance.proformainvoice.forms.ProformaInvoiceForm" action="/newproformaInvoice.do">
            <table cellSpacing="0" cellPadding="0" width="100%" border="0">
                <logic:equal  name="isCancelled" value="true">
                    <logic:equal name="showMessage" value="TRUE">
                    <tr><td align='right'><font class='NArialS'color='blue'><b><%=Constants.NO_MODIFY_RIGHTS%></b></font></td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr>
                    </logic:equal>
                    <tr>
                        <td align='right'>
                            <font class='NArialL'><font color='red'>Are you sure, you want to Cancel this Proforma Invoice &nbsp;&nbsp;</font></font>
                            <chiptrack:restrictedLink functionality='<%=Functionality.PRO_FORMA_INVOICE%>' action='<%=User.USER_ACTION_MODIFY%>' href='javascript:cancelInvoice();' onmouseover="window.status='Cancel this Proforma Invoice';return true" onmouseout="window.status='';return true"><img src='<%=chipTracContext%>/jsp/includes/images/confirm.gif' border='0'></chiptrack:restrictedLink>
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <a href="<%=chipTracContext%>/newproformaInvoice.do?action=searchInvoices" onMouseOver="window.status='Go Back to Main Proforma Invoice Menu';return true" onMouseOut="window.status='';return true">
                            <img src='<%=chipTracContext%>/jsp/includes/images/back.gif' border='0'>
                            </a>
                        </td>
                        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
                    </tr>
                    <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
                </logic:equal>
            </table>
            <center><span class="NArialW">Pro Forma Invoice</span></center>
            <center>&nbsp;&nbsp;<a href="javascript:printView(<bean:write name="proformaInvoiceForm" property="invoiceId"/>)" onMouseOver="window.status='Click for Printer Friendly Version';return true" onMouseOut="window.status='';return true" title="Click here for Printer Friendly version"><font class="NArialS"><b>[Printer-Friendly]</b></font></a></center>
            <nested:nest property="salesOrder">
            <table width="90%" cellspacing='0' cellpadding='0' border="0" align="center" class='NArialL'>
                <tr><td colspan='5'>&nbsp;</td></tr>
                <tr><td colspan='5' align="right"><font class='NArialL'>[<a href="<%=chipTracContext%>/newproformaInvoice.do?action=searchInvoices" onMouseOver="window.status='Click here to go to Proforma Invoice Main Menu';return true" onMouseOut="window.status='';return true">Proforma Invoice Main Menu</a>]&nbsp;&nbsp;</font></td></tr>
		        <tr><td colspan='5'>&nbsp;</td></tr>
                <tr><td colspan='5'><chiptrack:info styleClass='NArialL'/></td></tr>
                <tr><td colspan='5'><chiptrack:errors styleClass='NArialL'/></td></tr>
                <tr><td colspan='5'><img height=10 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></td></tr>
                <tr>
                    <td colspan="2" bgcolor='#FFFFEE' valign=top>
                        <table border="0" width="100%" class="NArialL">
                            <tr>
                                <td class="NArialL" bgcolor="#DEE1E2" >Invoice No.:</td>
                                <td>
                                    <bean:write name="proformaInvoiceForm" property="invoiceNo" />
                                </td>
                            </tr>
                            <tr>
                                <td class="NArialL" bgcolor="#DEE1E2" >Invoice Date:</td>
                                <td>
                                    <bean:write name="proformaInvoiceForm" property='invoiceDate'/>
                                </td>
                            </tr>
                        </table>
                    </td>
                    <td colspan="3"><img height=10 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></td>
                </tr>
                <tr><td colspan='5'><img height=10 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></td></tr>
                <tr height=30>
                    <td width="34%" class="NArialL" bgcolor="#DEE1E2" >Bill To:</td>
                    <td width='1%'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td>
                    <td widht="30%" class="NArialL">&nbsp;</td>
                    <td width='1%'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td>
                    <td width="34%"  bgcolor="#DEE1E2">Ship To:</td>
                </tr>
                <tr>
                    <td bgcolor='#FFFFEE' valign=top>
                        <table width="100%" class="NArialL">
                            <tr>
                                <td>
                                    <nested:write property="billingAddressAsHTML" filter="false"/>
                                    <%--<nested:text property="specifincationFileName" size="20" styleClass="txfield" maxlength='100' disabled="true"/>--%>
                                </td>
                            </tr>
			            </table>
                    </td>
                    <td width='1%'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td>
                    <td class="NArialL">&nbsp;</td>
                    <td width='1%'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td>
                    <td bgcolor='#FFFFEE' class="NArialL" valign=top>
                        <table width="100%" class="NArialL">
                            <tr>
                                <td>
                                    <nested:write property="shippingAddressAsHTML" filter="false"/>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tR>
                <tr>
                    <td class="NArialL">
                        <table width="100%" class="NArialL">
                            <tr height=30>
                                <td bgcolor='#DEE1E2'>Customer PO#</td>
                                <td bgcolor='#DEE1E2'>Sales Order#</td>
                            </tr>
                            <tr height=30>
                                <td bgcolor='#FFFFEE'>
                                    <nested:write property="customerPO"/>
                                </td>
                                <td bgcolor='#FFFFEE'>
                                    <nested:write property="salesOrderNo"/>
                                </td>
                            </tr>
                        </table>
                    </td>
                    <td width='1%'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td>
                    <td class="NArialL">
                        <table width="100%" class="NArialL">
                            <tr height=30>
                                <td bgcolor='#DEE1E2'> Order Date</td>
                                <td bgcolor='#DEE1E2'>Ship Via</td>
                            </tr>
                            <tr height=30>
                                <td bgcolor='#FFFFEE'>
                                    <nested:write property="bookingdateAsString"/>
                                </td>
                                <td bgcolor='#FFFFEE'>
                                    <nested:write property="shippingMethod"/>
                                </td>
                            </tr>
                        </table>
                    </td>
                    <td width='1%'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td>
                    <td class="NArialL">
                        <table width="100%" class="NArialL">
                            <tr height=30>
                                <td bgcolor='#DEE1E2'>Sales Person</td>
                                <td bgcolor='#DEE1E2'>Regional Rep</td>
                                <td bgcolor='#DEE1E2'>Del Terms</td>
                                <td bgcolor='#DEE1E2'>Pay Terms</td>
                            </tr>
                            <tr height=30>
                                <td bgcolor='#FFFFEE'>
                                    <nested:write property="salesPerson"/>
                                </td>

                                <td bgcolor='#FFFFEE'>
                                    <nested:write property="regionalRep"/>
                                </td>

                                <td bgcolor='#FFFFEE'>
                                    <nested:write property="deliveryTerms"/>
                                </td>

                                <td bgcolor='#FFFFEE'>
                                    <nested:write property="shippingTerms"/>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
        </nested:nest>
                <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tR>
                <tr>
                    <td colspan='5'>
                        <table width="100%" border=0 cellpadding="2" cellspacing="2">
                            <tr height=30>
                                <td class="NArialL" bgcolor='#DEE1E2' align=center>PO Line#</td>
                                <td class="NArialL" bgcolor='#DEE1E2' align=center>UM</td>
                                <td class="NArialL" bgcolor='#DEE1E2' align=center><bean:message key = "label.mfgPartNumber" /></td>
                                <td class="NArialL" bgcolor='#DEE1E2' align=center><bean:message key = "label.customerPartNumber" /></td>
                                <td class="NArialL" bgcolor='#DEE1E2' align=center nowrap>Product Description</td>
                                <td class="NArialL" bgcolor='#DEE1E2' align=center>Requested <br>Dock Date</td>
                                <td class="NArialL" bgcolor='#DEE1E2' align=center>Scheduled<br>Ship Date</td>
                                <td class="NArialL" bgcolor='#DEE1E2' align=center>Revised<br>Ship Date</td>
                                <td class="NArialL" bgcolor='#DEE1E2' align=center>Taxable</td>
                                <td class="NArialL" bgcolor='#DEE1E2' align=center>Invoice Qty</td>
                                <td class="NArialL" bgcolor='#DEE1E2' align=center>Unit <br>Price</td>
                                <td class="NArialL" bgcolor='#DEE1E2' align=center>Extended Price</td>
                            </tr>
                            <% double grandTotal = 0d; %>
                            <nested:iterate name="proformaInvoiceForm" property="lineItemList" id="proformaLineItem" indexId="lineItemIndex" type="com.scalar.chiptrack.finance.proformainvoice.ProformaInvoiceLineItem" >
                            <nested:equal value="true" property="selected">

                                <tr <% if( lineItemIndex.intValue() % 2 == 0 ){ %> bgcolor='#FFFFEE' <% } else { %> bgcolor='#DEE1E2' <% } %> >
                                <td class="NArialL" align="center">
                                    <nested:write name="proformaLineItem" property="poLineItemNo"/>
                                </td>
                                <td class="NArialL" align="center">
                                    ea
                                </td>
                                <td class="NArialL" align="center">
                                    <nested:write name="proformaLineItem" property="manufacturingPartNo"/>
                                </td>
                                <td class="NArialL" align="center">
                                    <nested:write name="proformaLineItem" property="customerPartNo"/>
                                </td>
                                <td class="NArialL" align="center">
                                    <nested:write name="proformaLineItem" property="description"/>
                                </td>
                                <td class="NArialL" align="center">
                                    <nested:write name="proformaLineItem" property="requestDate"/>
                                </td>
                                <td class="NArialL" align="center">
                                    <nested:write name="proformaLineItem" property="scheduleDate"/>
                                </td>
                                <td class="NArialL" align="center">
                                    <nested:write name="proformaLineItem" property="revisedDate"/>
                                </td>
                                <td class="NArialL" align="center">
                                    <nested:write name="proformaLineItem" property="isTaxableAsString"/>
                                </td>

                                <td class="NArialL" align="center">
                                    <nested:write name="proformaLineItem" property="qtyPulledStr"/>
                                </td>
                                <td class="NArialL" align="center">
                                    <nested:write name="proformaLineItem" property="unitPriceAsString"/>
                                </td>
                                <td class="NArialL" align=right  nowrap>
                                    <bean:write name="proformaLineItem" property="amountAsString"/>&nbsp;
                                </td>
                                    <%
                                        grandTotal += proformaLineItem.getAmountAsDouble();
                                    %>
                                </tr>
                            </nested:equal>
                            </nested:iterate>
                            <tr>
                                <td>&nbsp;</td>
                            </tr>
                            <tr>
                                <td colspan=11 bgcolor='#DEE1E2' align="right" valign=top>
                                    <font class='NArialL'>
                                        Grand Total:
                                    </font>
                                </td>
                                <td colspan=1 bgcolor='#DEE1E2' align="right" valign=top>
                                    <font class='NArialL'>
                                        <%= StringUtils.formatAmount(grandTotal, "$###,###.###") %>
                                    </font>
                                </td>
                            </tr>
                            <%--<logic:iterate id="lineItemMapObj" name="proformaInvoiceForm" property="lineItemsWithSubtotals" >
                            <logic:iterate id="proformaLineItem" name="lineItemMapObj" property="key" type="com.scalar.chiptrack.finance.proformainvoice.ProformaInvoiceLineItem">
                                <tr height=30>
                                    <td bgcolor='#FFFFEE' class="NArialL" align=center nowrap>
                                        <bean:write name="proformaLineItem" property="poLineItemNo"/>&nbsp;
                                    </td>

                                    <td bgcolor='#FFFFEE' class="NArialL" align=center nowrap>ea</td>
                                    <td bgcolor='#FFFFEE' class="NArialL" align=center nowrap>
                                        <bean:write name="proformaLineItem" property="manufacturingPartNo"/>&nbsp;
                                    </td>
                                    <td bgcolor='#FFFFEE' class="NArialL" align=center nowrap>
                                        <bean:write name="proformaLineItem" property="customerPartNo"/>&nbsp;
                                    </td>
                                    <td bgcolor='#FFFFEE' class="NArialL" align=center width=240>
                                        <bean:write name="proformaLineItem" property="description"/>&nbsp;
                                    </td>
                                    <td bgcolor='#FFFFEE' class="NArialL" align=center nowrap>
                                        <bean:write name="proformaLineItem" property="requestDate"/>&nbsp;
                                    </td>
                                    <td bgcolor='#FFFFEE' class="NArialL" align=center nowrap>
                                        <bean:write name="proformaLineItem" property="scheduleDate"/>&nbsp;
                                    </td>
                                    <td bgcolor='#FFFFEE' class="NArialL" align=center nowrap>
                                        <bean:write name="proformaLineItem" property="revisedDate"/>&nbsp;
                                    </td>
                                    <td bgcolor='#FFFFEE' class="NArialL" align=center nowrap>
                                        <bean:write name="proformaLineItem" property="isTaxableAsString"/>&nbsp;
                                    </td>
                                    <td bgcolor='#FFFFEE' class="NArialL" align=center nowrap>
                                        <bean:write name="proformaLineItem" property="qtyPulledStr"/>&nbsp;
                                    </td>
                                    <td bgcolor='#FFFFEE' class="NArialL" align=right  nowrap>
                                        <bean:write name="proformaLineItem" property="unitPriceAsString"/>&nbsp;
                                    </td>
                                    <td bgcolor='#FFFFEE' class="NArialL" align=right  nowrap>
                                        <bean:write name="proformaLineItem" property="amountAsString"/>&nbsp;
                                    </td>
                                </tr>
                            </logic:iterate>
                                <tr>
                                    <td colspan="1" bgcolor="#FFFFFF" class="NArialL" align="right">Sub Total</td>
                                    <bean:define id="subTotal" name="lineItemMapObj" property="value" type="com.scalar.chiptrack.sales.SubTotal"/>
                                    <td colspan="1" bgcolor="#FFFFFF" class="NArialL" align="right">
                                        <bean:write name="subTotal" property="subTotalQty" />
                                    </td>
                                    <td colspan="9">&nbsp;</td>
                                    <td colspan="1" bgcolor="#FFFFFF" class="NArialL" align="right">
                                        <bean:write name="subTotal" property="subTotalAmt" />
                                    </td>
                                </tr>
                        </logic:iterate>--%>
                        </table>
                    </td>
                </tr>                                
                <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tR>

                <tr>
                    <td colspan="5">
                        <table border="0">
                            <tr>
                                <td align="center" colspan="5" bgcolor='#DEE1E2' class="NArialL">
                                    Banking Information
                                </td>
                            </tr>
                            <tr>
                                <td bgcolor='#DEE1E2' class="NArialL">Bank Name</td>
                                <td bgcolor='#FFFFEE' class="NArialL"><bean:write name="proformaInvoiceForm" property='bankName'/>&nbsp;</td>
                                <td >&nbsp;</td>
                                <td bgcolor='#DEE1E2' class="NArialL">Address </td>
                                <td bgcolor='#FFFFEE' class="NArialL"><nested:write property='bankAddress1' />&nbsp;</td>
                            </tr>
                            <tr>
                                <td bgcolor='#DEE1E2' class="NArialL">City </td>
                                <td bgcolor='#FFFFEE' class="NArialL"><nested:write property='bankCity' />&nbsp;</td>
                                <td>&nbsp;</td>
                                <td bgcolor='#DEE1E2' class="NArialL">State</td>
                                <td bgcolor='#FFFFEE' class="NArialL"><nested:write property='bankState' />&nbsp;</td>

                            </tr>
                            <tr>
                                <td bgcolor='#DEE1E2' class="NArialL">Zip Code</td>
                                <td bgcolor='#FFFFEE' class="NArialL"><nested:write property='bankZipCode' />&nbsp;</td>
                                <td>&nbsp;</td>
                                <td bgcolor='#DEE1E2' class="NArialL">Country</td>
                                <td bgcolor='#FFFFEE' class="NArialL"><nested:write property='bankCountry' />&nbsp;</td>
                            </tr>
                            <tr>
                                <td bgcolor='#DEE1E2' class="NArialL">ABA</td>
                                <td bgcolor='#FFFFEE' class="NArialL"><bean:write name="proformaInvoiceForm" property='aba' />&nbsp;</td>
                                <td>&nbsp;</td>
                                <td bgcolor='#DEE1E2' class="NArialL">Acct</td>
                                <td bgcolor='#FFFFEE' class="NArialL"><bean:write name="proformaInvoiceForm" property='acct'/>&nbsp;</td>
                            </tr>
                            <tr>
                                <td bgcolor='#DEE1E2' class="NArialL">Swift code</td>
                                <td bgcolor='#FFFFEE' class="NArialL"><bean:write name="proformaInvoiceForm" property='swiftcode'/>&nbsp;</td>
                                <td colspan="3">&nbsp;</td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tR>
                <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tR>
            </table>
        </td>
    </tr>
    <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tR>
</table>
</html:form>
<!-- Footer starts here -->
<%@include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
</body>
</html>
<%-- <%}catch(Exception e){e.printStackTrace();}%>--%>
